from redis import StrictRedis
import logging


class Config(object):
    """配置父类"""
    DEBUG = True

    # mysql数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:cq@127.0.0.1:3306/information17"
    SQLALCHEMY_TRACK_MODIFICATIONS = True

    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    REDIS_NUM = 7

    # session配置
    SECRET_KEY = "sgiUBBRqLfVUWp9r4NQw5Vmd6PV5V1oxU3Cd9bIpnam07ttm38xwPzUDzMwoKvlr"

    # 设置存储session的数据类型
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT,db=REDIS_NUM)
    SESSION_USE_SIGNER = True
    SESSION_PERMANENT = False
    PERMANET_SESSION_LIFETIME = 86400 * 2


class DevelopmentConfig(Config):
    """开发模式的配置"""
    DEBUG =True
    # 设置开发环境日志级别
    LOG_LEVEL = logging.DEBUG


class ProdctionConfig(Config):
    """线上模式的设置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING
    # mysql数据库的配置信息
    # SQLALCHEMY_DATABASE_URI = "mysql://root:cq@服务器ip:3306/information17"


config_dict = {
    "development": DevelopmentConfig,
    "production": ProdctionConfig
}